package com.zt.bus.line.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.zt.bus.line.model.Driver;
import com.zt.bus.line.service.DriverService;
import com.zt.servlet.ReqBean;
import com.zt.servlet.RequestAttribute;
import com.zt.servlet.Response;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

@Controller
@RequestMapping(value = "/driver")
public class DriverController {

	@Autowired
	private DriverService driverService;

	@RequestMapping(value = "/query")
	@ResponseBody
	public JSONObject query(@RequestAttribute(ReqBean.NAME) ReqBean reqBean) {
		List<Driver> list = driverService.getAllDriver();
		JSONArray driverArray = new JSONArray();
		for (Driver driver : list) {
			driverArray.add(driver.toJson(driver));
		}
		return Response.response(driverArray);
	}
}
